#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>

void showfilelist(char *f)
{
	DIR *dir = opendir(f);
	struct dirent *a;
	struct stat buf;
	int i = 0;
	

	while (a = readdir(dir))
	{
		if(strcmp(a->d_name,".") != 0 && strcmp(a->d_name,"..") != 0 )
		{
			printf("%s \n",a->d_name);
			stat(a->d_name,&buf);
	//		printf("%d\n",S_ISDIR(buf.st_mode));

			if( S_ISDIR(buf.st_mode) == 1 )
			{	
				i++;
				char f2[100];
				strcpy(f2,f);	
				strcat(f2,"/");
				strcat(f2,a->d_name);
				showfilelist(f2);
			}
		}
	}
	closedir(dir);
	return ;
}

void main()
{
	showfilelist(".");
}